package moltencore.network.protocol;

import spark.network.protocol.Base;

public abstract class BubbleNotification extends Base {
	private BubbleData bubbleData;
	private static final int BUBBLE_DATA_OFFSET = Base.SIZE;
	private static final int BUBBLE_DATA_LENGTH = BubbleData.SIZE;

	protected static final int SIZE =
			Base.SIZE +
			BUBBLE_DATA_LENGTH;

	public BubbleNotification(boolean isReliable, byte[] typeBytes) {
		super(isReliable, typeBytes);
	}

	public BubbleData getBubbleData() {
		return bubbleData;
	}

	public void setBubbleData(BubbleData bubbleData) {
		this.bubbleData = bubbleData;
	}

	@Override
	public void getBytes(byte[] buffer) {
		super.getBytes(buffer);
		bubbleData.getBytes(buffer, BUBBLE_DATA_OFFSET);
	}

	@Override
	public void fill(byte[] buffer) {
		super.fill(buffer);
		if(bubbleData == null) {
			bubbleData = new BubbleData();
		}
		bubbleData.fill(buffer, BUBBLE_DATA_OFFSET);
	}

	@Override
	public int getSize() {
		return SIZE;
	}
}
